package com.winning.pmph.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Table;
import java.util.concurrent.CopyOnWriteArrayList;

@Data
@Table(name = "TAG")
@NoArgsConstructor
public class Tag extends BaseEntity {

    private static final long serialVersionUID = 1L;

    public static final String BOOK_CATEGORY_ID = "e4d0874b39454005afe298541798bebb";

    /** ID */
    @TableId
    private String id;
    /** 标签名称 */
    private String name;
    /** 父节点ID */
    private String parentId;
    /** 分类编码 */
    private String tagCode;
    /** 旧分类编码 */
    private String oldTagCode;
    /** 对应级别 1 一级 2 二级 以此类推 */
    private int level;
    /** 当前节点在所在层级中的顺序。从0开始 */
    @TableField("`index`")
    private int index;
    /** 所属一级节点的ID */
    private String rootId;
    /** 自定义标记 */
    private boolean selfDefinedFlag;

    @TableField(exist = false)
    private String parentCode;
    @TableField(exist = false)
    private String oldParentCode;
    // 前端标记, 是否是转移的标签;
    @TableField(exist = false)
    private boolean transferFlag;
    /**
     * 同步操作: add, update, delete
     */
    @TableField(exist = false)
    private String option;
    @TableField(exist = false)
    private CopyOnWriteArrayList<Tag> children;
    @TableField(exist = false)
    private int bookCount;  // 图书分类专用, 改分类下图书数量;

    public Tag(String id, String name, String parentId, String tagCode, int level, int index, String rootId, boolean selfDefinedFlag) {
        this.id = id;
        this.name = name;
        this.parentId = parentId;
        this.tagCode = tagCode;
        this.level = level;
        this.index = index;
        this.rootId = rootId;
        this.selfDefinedFlag = selfDefinedFlag;
    }
}
 